<?php
namespace app\home\controller;

use app\BaseController;
use app\home\model\Article;
use app\home\model\Seo;
use think\facade\View;
use app\api\model\Usage;


class Pages extends BaseController
{
    public function index()
    {
        $hot_page = Article::getByOrder('hot_order_desc', 7);
        $hot_page1 = [];
        $hot_page2 = [];
        foreach($hot_page as $index => $page){
            if($index < 2){
                array_push($hot_page1,$page);
            }else{
                array_push($hot_page2, $page);
            }
        }
        View::assign('pages_hot2', $hot_page2);
        View::assign('pages_hot1_1', $hot_page1[0]);
        View::assign('pages_hot1_2', $hot_page1[1]);
        View::assign('pages', Article::getByOrder('date_desc', 60));
        View::assign('kw', Seo::getKeywords());
        View::assign('desc', Seo::getDesc());
        $usage = new Usage;
        $usage->save([
            'access_page'=>'Other',
            'access_time'=>date('Y-m-d', time()),
            'access_ip'=>$_SERVER["REMOTE_ADDR"]
        ]);
        return View::fetch();
    }
}
